﻿//Remove RobustDebug for production applications
load("RobustDebug.asc");
load("LoadConfigFun.asc");
load("MyTrace.asc");
load("CartServerManager.asc");
load("AccountManager.asc");
load("VisterManager.asc");
//
var configs;

function initVars(){
	configs=LoadConfigFile("config.txt");
}


application.onAppStart = function()
{
	initVars();
	trace("["+application.name+"]started!!");
}

application.onConnect = function(client,clientType,args)
{
	trace(clientType+"["+args+"]: connected!");
	client.clientType=clientType;
	client.app=this;
	
	
	if(clientType=="CS"){
		AddCartServer(client,args);
		application.acceptConnection(client);
	}
	else if(clientType=="AC"){
		//account
		AddAccountUser(client,args[0],args[1],args[2]);
	}
	else if(clientType=="VT"){
		//vister
		AddVisterUser(client,args[0]);
	}
}
application.onDisconnect = function(client)
{
	trace(client.ip+"["+client.clientType+"]: disconnected!!");
	if(client.clientType=="CS"){
		DelCartServer(client)
	}
	else if(client.clientType=="AC"){
		//account
		DelAccountUser(client);
	}
	else if(client.clientType=="VT"){
		//vister
		DelVisterUser(client);
	}
}



function CallClient(c,FunName,msg){
	c.call(FunName,null,msg);
}
